import { SixtyCopyView } from "../sixty/SixtyCopyView";
import { IClean } from "../../../../../com/gengine/core/IClean";
import { CrossAryadevaSecretCopyInfoView } from "./CrossAryadevaSecretCopyInfoView";
import { SixtyMaterialPanel } from "../sixty/SixtyMaterialPanel";
import { SixtySkillPropListPanel } from "../sixty/SixtySkillPropListPanel";
import { Global } from "../../../../../com/gengine/global/Global";
import { SixtyCopySmeltButton } from "../sixty/SixtyCopySmeltButton";
import { Cache } from "../../../cache/Cache";
import { SPlayerItem } from "../../../../../Message/Public/SPlayerItem";
import { CopyConfig } from "../../../resource/CopyConfig";
import { CopyType } from "../CopyType";
import { ItemData } from "../../../resource/info/ItemData";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SelectCopyDropTimeView } from "./SelectCopyDropTimeView";
import { GameDefConfig } from "../../../resource/GameDefConfig";
type int = number;
//class CrossAryadevaSecretCopyView
    
    export  class CrossAryadevaSecretCopyView extends SixtyCopyView implements IClean
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            this._infoView = new CrossAryadevaSecretCopyInfoView();
            this._infoView.show();
            _smeltPanel = new SixtyMaterialPanel();
            _smeltPanel.addEventListener(SixtyMaterialPanel.MATERIALPANEL_MINIMIZE, onSmeltPanelMinimize);
            _skillsPanel = new SixtySkillPropListPanel(5);
            _skillsPanel.x = Global.stage.stageWidth / 2 - 235;
            _skillsPanel.y = Global.stage.stageHeight - 205;
            this.addChild(_skillsPanel);
            _smeltMinimize = new SixtyCopySmeltButton();
            _smeltMinimize.layer = null;
            _smeltMinimize.x = 10;
            _smeltMinimize.y = 10;
            _smeltMinimize.addEventListener(flash.events.MouseEvent.CLICK, this.onMinimizeBtnClick);
            this._infoView.bodySp.addChild(_smeltMinimize);
            return;
        }

        public updatePosition(): void
        {
            this._infoView.updatePosition();
            return;
        }

        public updataKillBossInfo(arg1: string): void
        {
            if (this._infoView) 
            {
                this._infoView.updataKillBossInfo(arg1);
            }
            return;
        }

        public updataAwardInfo(arg1: Array<any>): void
        {
            if (this._infoView) 
            {
                this._infoView.updataAwardInfo(arg1);
            }
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            if (this._infoView) 
            {
                this._infoView.updateLeftTime(arg1);
            }
            return;
        }

        public /* override */ updateItems(): void
        {
            var loc4=null;
            var loc1=Cache.instance.copy.crossASCopyItems;
            Cache.instance.copy.crossASCopyMaterialDic = new Map<any, any> /* flash.utils.Dictionary */();
            var loc2=[];
            var loc3=[];
            var loc5=0;
            while (loc5 < loc1.length) 
            {
                loc4 = loc1[loc5] as SPlayerItem;
                if (CopyConfig.instance.isCurrentCopySkill(CopyType.CROSS_ARYADEVA_SECRET_COPY, loc4.itemCode)) 
                {
                    loc2.push(new ItemData(loc4));
                }
                else 
                {
                    loc3.push(new ItemData(loc4));
                    Cache.instance.copy.crossASCopyMaterialDic[loc4.itemCode] = loc4.itemAmount;
                }
                ++loc5;
            }
            if (_skillsPanel) 
            {
                _skillsPanel.updateSkills(loc2);
            }
            if (_smeltPanel) 
            {
                _smeltPanel.updateMaterials(loc3);
            }
            if (this._infoView) 
            {
                this._infoView.updatacopyMaterial(loc3);
            }
            return;
        }

        public addGuide(): void
        {
            if (_smeltMinimize && this._infoView) 
            {
                this._infoView.showPanel();
                _smeltMinimize.addGuide();
            }
            return;
        }

        public addSecondStepGuide(): void
        {
            if (_smeltPanel) 
            {
                _smeltPanel.addGuide();
            }
            return;
        }

        public addThirdlyStepGuide(): void
        {
            if (_skillsPanel) 
            {
                _skillsPanel.addGuide();
            }
            return;
        }

        public /* override */ updateView(): void
        {
            return;
        }

        protected /* override */ onMinimizeBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            super.onMinimizeBtnClick(arg1);
            _smeltMinimize.removeGuide();
            if (Cache.instance.copy.guideStep == 1) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.CrossAryadevaSecretCopyAddGuideStepSecond));
            }
            return;
        }

        public rewardViewShow(arg1: Array<any>, arg2: Boolean=false): void
        {
            if (this._getRewardView == null) 
            {
                this._getRewardView = new SelectCopyDropTimeView();
            }
            this._getRewardView.itemData(arg1);
            this._getRewardView.multipleOptions = GameDefConfig.instance.getCopyDropTime(1);
            this._getRewardView.showReturnBtn(arg2);
            this._getRewardView.show();
            return;
        }

        public rewardViewHide(): void
        {
            if (this._getRewardView && !this._getRewardView.isHide) 
            {
                this._getRewardView.dispose();
            }
            return;
        }

        public stopLeftTime(): void
        {
            if (this._infoView) 
            {
                this._infoView.stopLeftTime();
            }
            return;
        }

        public clean(): void
        {
            if (_smeltMinimize && _smeltMinimize.parent) 
            {
                _smeltMinimize.parent.removeChild(_smeltMinimize);
                _smeltMinimize.removeEventListener(flash.events.MouseEvent.CLICK, this.onMinimizeBtnClick);
                _smeltMinimize = null;
            }
            if (this._infoView && this._infoView.parent) 
            {
                this._infoView.clean();
                this._infoView.parent.removeChild(this._infoView);
                this._infoView = null;
            }
            if (_smeltPanel && _smeltPanel.parent) 
            {
                _smeltPanel.hide();
                _smeltPanel.removeEventListener(SixtyMaterialPanel.MATERIALPANEL_MINIMIZE, onSmeltPanelMinimize);
                _smeltPanel = null;
            }
            if (_skillsPanel && _skillsPanel.parent) 
            {
                _skillsPanel.parent.removeChild(_skillsPanel);
                _skillsPanel = null;
            }
            if (this._getRewardView && this._getRewardView.parent) 
            {
                this._getRewardView.hide();
                this._getRewardView = null;
            }
            return;
        }

        /* internal */ /* var */_infoView: CrossAryadevaSecretCopyInfoView;

        /* internal */ /* var */_getRewardView: SelectCopyDropTimeView;
    }
